package com.lanju.controller;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lanju.common.SpringUtils;
import com.lanju.entity.User;
import com.lanju.service.HouseFlagService;
import com.lanju.service.JedisService;

@Controller
@RequestMapping("houseFlag")
public class HouseFlagController {

	@Autowired
	private HouseFlagService houseFlagService;
	 @Resource
	 JedisService jedisService;
	
	/***
	 * 获取房子标记
	 * @return
	 */
	@RequestMapping("getAllFlagList")
	@ResponseBody
	public Map<String,Object> getAllFlagList(){
		Map<String,Object>  result=null;
		try {
			result=houseFlagService.getAllFlagList();
		} catch (Exception e) {
			result=null;
			e.printStackTrace();
		}
		return result;
	}
	
	/***
	 * 新增标签类型
	 * @return
	 */
	@RequestMapping("insertFlagType")
	@ResponseBody
	public Map<String,Object> insertFlagType(HttpServletRequest request, HttpServletResponse response,HttpSession session){
		Map<String, Object> param = SpringUtils.getParameterMap(request);
		User user =(User) session.getAttribute("userModel");
		param.put("userId", user.getUserId());
		return houseFlagService.insertFlagType(param);
	}
	
	/***
	 * 删除标签类型
	 * @return
	 */
	@RequestMapping("delFlagType")
	@ResponseBody
	public Map<String,Object> delFlagType(HttpServletRequest request, HttpServletResponse response){
		Map<String, Object> param = SpringUtils.getParameterMap(request);
		return houseFlagService.delFlagType(param);
	}
	
	/***
	 * 更新标签类型
	 * @return
	 */
	@RequestMapping("updateFlagType")
	@ResponseBody
	public Map<String,Object> updateFlagType(HttpServletRequest request, HttpServletResponse response){
		Map<String, Object> param = SpringUtils.getParameterMap(request);
		return houseFlagService.updateFlagType(param);
	}
	
	/***
	 * 获取标签类型列表
	 * @return
	 */
	@RequestMapping("queryFlagTypeList")
	@ResponseBody
	public Map<String,Object> queryFlagTypeList(HttpServletRequest request, HttpServletResponse response,HttpSession session){
		Map<String, Object> param = SpringUtils.getParameterMap(request);
		User user =(User) session.getAttribute("userModel");
		param.put("userId", user.getUserId());
		return houseFlagService.queryFlagTypeList(param);
	}
}
